<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>无标题文档</title>
	<style type="text/css">
		<!--
		body {
		margin-left: 3px;
		margin-top: 0px;
		margin-right: 3px;
		margin-bottom: 0px;
		}
		.STYLE1 {
		color: #e1e2e3;
		font-size: 12px;
		}
		.STYLE6 {color: #000000; font-size: 12; }
		.STYLE10 {color: #000000; font-size: 12px; }
		.STYLE19 {
		color: #344b50;
		font-size: 12px;
		}
		.STYLE21 {
		font-size: 12px;
		color: #3b6375;
		}
		.STYLE22 {
		font-size: 12px;
		color: #295568;
		}
		-->
	</style>
	<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td height="30">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td height="24" bgcolor="#353c44">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td>
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td width="6%" height="19" valign="bottom">
													<div align="center">
														<img src="images/tb.gif" width="14" height="14" alt="" />
													</div>
												</td>
												<td width="94%" valign="bottom">
													<span class="STYLE1" onclick="tmp();">活动商品总览</span>
												</td>
											</tr>
										</table>
									</td>
									<td></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table id="right_main_content" width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
				</table>
			</td>
		</tr>
		<tr>
			<td height="30">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="33%"></td>
						<td width="67%"></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
<script type="text/javascript">
//*

var actionString='预览';
var _length=14;
var _year='2012';
var _month='8'; // js date : month += 1;
var _day='20';
var pData=new Array();
pData[0]=new Array('1','','','美的A20微波炉','6 折','21000','19208','21956');
pData[1]=new Array('2','','','美的A22电烤箱','5 折','21000','16251','22956');
pData[2]=new Array('3','','','长虹51存彩色电视机','5 折','21000','16251','22956');
pData[3]=new Array('4','','','美的T93滚筒洗衣机','5 折','21000','16251','22956');
pData[4]=new Array('5','','','美的A79电烤箱','5 折','21000','16251','22956');
pData[5]=new Array('6','','','长虹59存彩色电视机','5 折','21000','16251','22956');
pData[6]=new Array('7','','','美的H33滚筒洗衣机','5 折','21000','16251','22956');
pData[7]=new Array('8','','','长虹51存彩色电视机','5 折','21000','16251','22956');
pData[8]=new Array('9','','','美的T93滚筒洗衣机','5 折','21000','16251','22956');
pData[9]=new Array('10','','','美的A79电烤箱','5 折','21000','16251','22956');
pData[10]=new Array('11','','','长虹59存彩色电视机','5 折','21000','16251','22956');
pData[11]=new Array('12','','','美的H33滚筒洗衣机','5 折','21000','16251','22956');
pData[12]=new Array('13','','','长虹59存彩色电视机','5 折','21000','16251','22956');
pData[13]=new Array('14','','','美的H33滚筒洗衣机','5 折','21000','16251','22956');

var productions = new Array();

var getCompareDates=function(date1,date2){ // max is first then TRUE
	if(date1.getFullYear()>date2.getFullYear())return true;
	if(date1.getMonth()>date2.getMonth())return true;
	if(date1.getDate()>date2.getDate())return true;
	if(date1.getHours()>date2.getHours())return true;
	if(date1.getMinutes()>date2.getMinutes())return true;
	if(date1.getSeconds()>date2.getSeconds())return true;
	if(date1.getMilliseconds()>date2.getMilliseconds())return true;
	return false;
}

var getDate=function(addDay){
	var d=new Date();
	d.setFullYear(_year,_month,_day);
	d.setDate(d.getDate()+addDay);
	return d;
}

var getFormatDateString=function(addDay){
	var d=new Date();
	d.setFullYear(_year,_month,_day);
	d.setDate(d.getDate()+addDay);
	return d.getFullYear() + ' 年 ' + (d.getMonth()+1)+' 月 '+d.getDate()+' 日';
}

var getOrderStyle=function(value,addDay){
	if(stateEditOrder){
		var d1=getDate(addDay);
		var d2=new Date();
		if(getCompareDates(d1,d2)){ // tomorrow and after it - can edit
			return '<input type="text" style="width: 16px;" value="'+value+'" />';
		}
	}
	return value;
}

function tmp(){
	var post_data = {424:'order', 321: null, 2312: 234};
	$.post(
		//"/app/index.php?d=api&c=product&m=get_product_list",
		"/app/index.php?d=api&c=product&m=set_products_order",
		post_data,
		function(result){
			//console.log(result);
			/*for(var i=0;i<imax;i++){
				if(i>=dCount){
					break;
				}
				var production={};
				production.order=result.product_list[i].product_order;
				production.action=actionString;
				if(result.product_list[i].product_date==null || result.product_list[i].product_date==''){
					production.date=getFormatDateString(i);
				}else{
					production.date=result.product_list[i].product_date;
				}
				production.name=result.product_list[i].product_name;
				production.discount=result.product_list[i].product_discount;
				production.defaultVoteCount=result.product_list[i].product_order;
				production.voteCount=result.product_list[i].product_order;
				production.commentCount=result.product_list[i].product_order;
				productions[i]=production;
			}*/
		},"json");
	/*$.post(
		"demo.php",
		{},
		function(result){
			alert(result.abc);
		},"json");*/
}
var format=function(){
	var dCount=pData.length;
	var imax=_length;

	for(var i=0;i<imax;i++){
		if(i>=dCount){
			break;
		}
		var production={};
		production.order=pData[i][0];
		production.action=pData[i][1];
		if(pData[i][2]==''){
			production.date=getFormatDateString(i);
		}else{
			production.date=pData[i][2];
		}
		production.name=pData[i][3];
		production.discount=pData[i][4];
		production.defaultVoteCount=pData[i][5];
		production.voteCount=pData[i][6];
		production.commentCount=pData[i][7];
		productions[i]=production;
	}
}();

var stateEditOrder=false;
var formatHTML=function(){
	var htmlObj=document.getElementById("right_main_content");
	htmlObj.innerHTML='';
	var thOrder='<a href="#" onclick="return setOrder(false);">点击调整排序</a>';
	if(stateEditOrder){
		thOrder='<a href="#" onclick="return setOrder(true);">保存</a> | <a href="#" onclick="return setOrder(false);">取消</a>';
	}
	var _content='<tr>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">排序('+thOrder+')</span></div></th>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">商品展示与设置</span></div></th>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">日期</span></div></th>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">商品名称</span></div></th>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">预定折扣</span></div></th>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">预定投票数</span></div></th>'
	+'\r\n<th width="12%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">实际投票数</span></div></th>'
	+'\r\n<th width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">评论数</span></div></th>'
	+'\r\n</tr>';
	var htmlStr={};
	htmlStr.tr={};
	htmlStr.order={};
	htmlStr.action={};
	htmlStr.date={};
	htmlStr.name={};
	htmlStr.discount={};
	htmlStr.defaultVoteCount={};
	htmlStr.voteCount={};
	htmlStr.commentCount={};

	htmlStr.tr.start='\r\n<tr>';
	htmlStr.order.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">';
	htmlStr.order.end='</div></td>';
	htmlStr.action.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><a href="pinfo.html">';
	htmlStr.action.end='</a></div></td>';
	htmlStr.date.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">';
	htmlStr.date.end='</div></td>';
	htmlStr.name.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">';
	htmlStr.name.end='</div></td>';
	htmlStr.discount.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">';
	htmlStr.discount.end='</div></td>';
	htmlStr.defaultVoteCount.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">';
	htmlStr.defaultVoteCount.end='</div></td>';
	htmlStr.voteCount.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><a href="tplist.html">';
	htmlStr.voteCount.end='</a></div></td>';
	htmlStr.commentCount.start='\r\n<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><a href="pllist.html">';
	htmlStr.commentCount.end='</a></div></td>';
	htmlStr.tr.end='\r\n</tr>';
	var imax=productions.length;
	for(var i=0;i<imax;i++){
		var _production = productions[i];
		_content+=htmlStr.tr.start
		+htmlStr.order.start+getOrderStyle(_production.order,i)+htmlStr.order.end
		+htmlStr.action.start+actionString+htmlStr.action.end
		+htmlStr.date.start+_production.date+htmlStr.date.end
		+htmlStr.name.start+_production.name+htmlStr.name.end
		+htmlStr.discount.start+_production.discount+htmlStr.discount.end
		+htmlStr.defaultVoteCount.start+_production.defaultVoteCount+htmlStr.defaultVoteCount.end
		+htmlStr.voteCount.start+_production.voteCount+htmlStr.voteCount.end
		+htmlStr.commentCount.start+_production.commentCount+htmlStr.commentCount.end
		+htmlStr.tr.end;
	}
	htmlObj.innerHTML=_content;
};
setTimeout('formatHTML()',0);

var updateOrders=function(){
}

var setOrder=function(saveOrder){
	stateEditOrder=!stateEditOrder;
	formatHTML();
	if(saveOrder){
		updateOrders();
	}
	return false;
}
</script>
</html>